var express = require('express');
var router = express.Router();


//中间件 (检查是否已经登录，若没有登录则无权访问详情页)
function isLogin(req,res,next){
  console.log(req.session.username,22);   
  if(!req.session.username){
     res.redirect('/login')
  }else{
      next()
  }
}
router.get('/',isLogin, function(req, res) {
  //判断是否登陆
  res.render('index',{username:req.session.username});
});

module.exports = router;
